package cn.wsalix.spring.utils;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.wsalix.admin.entity.BasicMapping;
import cn.wsalix.admin.repository.BasicMenuRepository;

@Component("requestMappingTraverse")
public class RequestMappingTraverse implements Traverse<RequestMapping> {
	@Autowired
	private BasicMenuRepository requestMenuRepository;

	@Override
	public void process(RequestMapping annotation) {
		for (String requestUrl : annotation.value()) {
			BasicMapping requestMenu = new BasicMapping();
			requestMenu.setUrl(requestUrl);
			requestMenu.setCreatedDate(new Date());// DateTime.now());
			requestMenu.setCreatedBy(0l);
			requestMenuRepository.save(requestMenu);
		}// Arrays.toString(requestMapping.value())
	}

}
